<%--
  Created by IntelliJ IDEA.
  User: Shinelon
  Date: 2018-08-17
  Time: 15:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/jquery-3.2.1.min.js"></script>
<link rel="stylesheet" href="${pageContext.request.contextPath}/static/bootstrap/css/bootstrap.css"/>

<link rel="stylesheet" href="${pageContext.request.contextPath}/static/table/bootstrap-table.min.css"/>

<script type="text/javascript" src="${pageContext.request.contextPath}/static/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/table/bootstrap-table.min.js"></script>
<script type="text/javascript"
        src="${pageContext.request.contextPath}/static/table/locale/bootstrap-table-zh-CN.min.js"></script>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/sweetalert/sweetalert.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/static/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/scwuyefei.js"></script>
<html>
<head>
    <title>Title</title>
</head>

<script type="text/javascript">
    $(function(){
        $("#dg").bootstrapTable({
            url:'${pageContext.request.contextPath}/../../order/list',
            columns: [
                {
                    field: 'id',
                    title: 'id',
                    visible : false,
                },{
                    field: 'orderid',
                    title: '档案号',
                },{
                    field: 'name',
                    title: '档案名称',
                },{
                    field: 'date',
                    title: '建档日期',
                },{
                    field: 'fname',
                    title: '缴费名称',
                },{
                    field: 'remark',
                    title: '备注',
                },{
                    field: 'srecords',
                    title: 'list集合',
                    visible : false,
                }
            ],
            contentType:"application/x-www-form-urlencoded",
            queryParamsType: '',
            //修改分页的默认对数
            //offset,limit
            height: 700,
            pageNumber: 1,
            pageSize: 5,
            pagination:true,
            queryParams: queryParams,
            sidePagination:'server',
            detailView:true,
            //当点击详细图标展开详细页面的时候触发。
            onExpandRow:function(index, row, $detail){
                console.log("123123")
                var aa=$detail.html("<table></table>").find('table');
                aa.bootstrapTable({
                    url: '${pageContext.request.contextPath}/../srecord/cc',
                    columns: [{
                        field: 'id',
                        title: 'id',
                        visible : false,
                    },{
                        field: 'lasttime',
                        title: '上次读数'
                    },{
                        field: 'sdate',
                        title: '上次日期'
                    },{
                        field: 'jdate',
                        title: '缴费期限'
                    },{
                        field: 'house.sale.name',
                        title: '楼盘',
                        visible : false,
                    },{
                        field: 'house.floor',
                        title: '楼层',
                        visible : false,
                    },{
                        field: 'house.danyuan.name',
                        title: '房屋信息',
                        formatter: function (value, row, index) {
                            return "百家小区 "+house.sale.name+" "+house.danyuan.name+" "+house.floor+"层";
                        }
                    },{
                        field: 'costitem.name',
                        title: '收费名称'
                    },{
                        field:'num',
                        title:'用量',
                    },{
                        field:'zmoney',
                        title:'金额',
                    },{
                        field:'type',
                        title:'是否缴费',
                        formatter: function (value, row, index) {
                            if(row.type()==1){
                                return "未交费";
                            }else if(row.type==2){
                                return "已缴费";
                            }
                        }

                    }
                    ],
                }) ;
            }

        })
    })
    function queryParams(params) {

        var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
            'pageSize': params.pageSize,  //页面大小
            'pageNumber': params.pageNumber, //页码
            'date':$("#test6").val(),
            'danhao':$("#danhao").val(),
        };
        return temp;
    };


    function search1() {
        var opt = $("#dg").bootstrapTable('getOptions');

        $.post('${pageContext.request.contextPath}/../../order/list', {
            'date':$("#test6").val(),
            'danhao':$("#danhao").val(),
            'pageSize': opt.pageSize,
            'pageNumber': 1
        }, function (data) {

            //重新给table绑定数据
            $("#dg").bootstrapTable("load", data);
        });
    }
</script>

<body>
<div>
    <form class="form-inline">
        <%--按时间查询--%>
        请选择时间范围：
        <div class="layui-input-inline">
            <input type="text" style="width: 230px;" class="layui-input form-control" id="test6" placeholder=" ~ ">
        </div>
        &nbsp;
        <%--按供货商查询--%>
        档案号:
        <%--<input id="firstDate" type="text" class="form-control">--%>
        <input type="text" id="danhao" class="form-control">

        <button onclick="search1()" type="button" class="btn btn-default">查询</button>
    </form>
    <table id="dg"></table>
</div>
</body>
</html>
